package geez.widget;

import com.google.gwt.user.client.ui.Widget;

public class ZebraTable extends GFlexTable {
    private String oddRowCss;
    private String evenRowCss;

    public ZebraTable(String oddRowCss, String evenRowCss) {
        this.oddRowCss = oddRowCss;
        this.evenRowCss = evenRowCss;
    }

    public GFlexTable set(int row, int column, Widget widget) {
        super.set(row, column, widget);
        new GRow(this, row).css((row % 2) == 0 ? oddRowCss : evenRowCss);
        return this;
    }

    public GRow addRow(Widget... widgets) {
        GFlexTable.GRow row = super.addRow(widgets);
        return row.css((row.getRowIndex() % 2) == 0 ? oddRowCss : evenRowCss);
    }
}
